<%--
  Created by IntelliJ IDEA.
  User: hongcy
  Date: 16-3-20
  Time: 下午9:08
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ include file="/include/taglib.jsp" %>
<div>
    <form method="post" action="${ctx}/mulanweb/admin/seller/save" id="ff">
        <table cellspacing="5" style="margin: 0 5px;">
            <tr>
                <td>商家名称:</td>
                <td><input type="text" name="sellerName" class="easyui-textbox"
                           data-options="required:true,validType:{length:[1,30]}" style="width: 260px;"/></td>
            </tr>
            <tr>
                <td>商家账号:</td>
                <td><input type="text" name="username" class="easyui-textbox"
                           data-options="required:true,validType:{length:[1,20]}" style="width: 260px;"/></td>
            </tr>
            <tr>
                <td>商家类型:</td>
                <td><input type="radio" value="25" checked="checked" name="type" id="qy" onclick="getTypeId()"/>
                    <label for="qy">企业商家</label>&nbsp;&nbsp;&nbsp;&nbsp;
                    <input type="radio" value="26" name="type" id="gr" onclick="getTypeId()"/>
                    <label for="gr">个人商家</label>
                <input type="hidden" name="typeId" id="typeId" value="25"/>
            </tr>
            <tr id="parentSeller" style="display:none;">
                <td>父商家主键:</td>
                <td><input type="text" name="parentId" class="easyui-textbox"
                           data-options="validType:{length:[1,20]}" style="width: 260px;"/></td>
            </tr>
            <tr>
                <td>是否预约:</td>
                <td><input type="radio" value="1" checked="checked" name="yuyue" id="xy" onclick="getYuyue()"/>
                    <label for="xy">是</label>&nbsp;&nbsp;&nbsp;&nbsp;
                    <input type="radio" value="0" name="yuyue" id="bxy" onclick="getYuyue()"/>
                    <label for="bxy">否</label>
                    <input type="hidden" name="typeId" id="yuyue" value="1"/>
            </tr>
            <tr>
                <td>主营类目:</td>
                <td><input type="checkbox" value="23" checked="checked" name="category" id="ticket" onclick="getCategory()"/>
                    <label for="ticket">门票券票</label>&nbsp;&nbsp;&nbsp;&nbsp;
                    <input type="checkbox" value="24" name="category" id="chartered" onclick="getCategory()"/>
                    <label for="chartered">包车陪游</label>
                    <input type="hidden" name="categoryId" id="categoryId" value="23"/></td>
            </tr>
            <tr>
                <td>城市:</td>
                <td><input id="form-city" style="width: 260px;"/></td>
                <input type="hidden" name="cityId" id="cityId"/></td>
            </tr>
            <tr>
                <td>email:</td>
                <td><input type="text" name="email" class="easyui-textbox"
                           data-options="required:true" style="width: 260px;"/></td>
            </tr>
            <tr>
                <td>电话:</td>
                <td><input class="easyui-textbox" name="mobile" data-options="required:true,precision:0," style="width: 260px;"/></td>
            </tr>
            <tr>
                <td>详情介绍:</td>
                <td><input type="text" name="description" class="easyui-textbox"
                           data-options="multiline:true,required:true,validType:{length:[1,200]}"
                           style="width:260px;height:80px"/></td>
            </tr>
            <tr>

                <p><td colspan="2">默认登陆密码为:123456</td></p>
            </tr>
        </table>
    </form>
</div>

<script>
        function getTypeId(){
            var typeId = $("td input:radio[name=type]:checked").val();
            if(typeId && typeId == 26){
                $("#parentSeller").removeAttr("style");
            }else{
                $("#parentSeller").css("display","none");
            }
            $("#typeId").val(typeId);
        }

        function getYuyue(){
            var yuyue = $("td input:radio[name=yuyue]:checked").val();
            $("#yuyue").val(yuyue);
        }
        function getCategory(){
            var typeId = $("td input:checkbox[name=category]:checked");
            if(typeId.length ==2 ){
                $("#typeId").val(22);
            }else if(typeId.length ==1 ){
                $("#typeId").val($(typeId).val());
            }else{
                $("#typeId").val("");
            }
        }
    $(function(){
        $("#form-city").combobox({
            required: true,
            url: '${ctx}/mulanweb/common/city/search',
            fit: true,
            panelHeight: 200,
            valueField: 'Id',
            textField: 'NameCn',
            editable: false,
            queryParams: {
                PageSize: 100,
                PageNumber: 1
            },
            onChange:function(newV,oldV){
                $("#cityId").val(newV);
            },
            loadFilter: function (data) {
                var result = [];
                var currentSize = data.PageSize;
                var totalSize = data.TotalRow;
                if (data.ReturnCode == 1 && currentSize >= totalSize) {
                    if (data.DataList.length > 0) {
                        for (var tt = 0; tt < data.DataList.length; tt++) {
                            result.push({Id: data.DataList[tt].Id, NameCn: data.DataList[tt].NameCn});
                        }
                    }
                } else {
                    Constant.showMessage("地点信息已超过最大值");
                }
                return result;
            }
        });
    })
</script>